home *** CD-ROM | disk | FTP | other *** search
- Path: oasis.novia.net!not-for-mail
- From: nicatt@oasis.novia.net (Nicatt)
- Newsgroups: comp.lang.c
- Subject: atof/atoi
- Date: 10 Feb 1996 16:40:25 GMT
- Organization: Novia Internetworking <> 28.8kbps dialup; 402/390-2NET
- Message-ID: <4fihpp$j5q@nntp.novia.net>
- NNTP-Posting-Host: oasis.novia.net
- X-Newsreader: TIN [UNIX 1.3 BETA-950824-color PL0]
-
-
- I am a rookie.
-
- I have been through the faq and three C books and cannot find *how*
- to use atof/atoi. Each mentions them and their purpose, but none explains
- how to use them.
-
- I wrote a program that works fine. However, one of the requirements
- is to trap for alpha characters. If I use "gets", my Y/N response
- prior to the loop below falls through. I can define *catch* as a char
- and trap the character after scanf (ex: catch=getchar(); ) but I have
- not figured how to use that to my advantage to break the loop, reask for
- the correct value to be entered, and restart the loop at that point.
-
- This is an internet class and the instructor said to use atof.
-
- The question is, how do you use atof?
-
- for(count=0; count<STUDENTS; count++)
- { printf("\nWhat is student %i's grade average ", (count+1));
- for(count2=0; count2<GRADES; count2++)
- { printf("in class number %i?\n ", (count2+1));
- scanf(" %f", &number);
- grades[count][count2]=number;
- printf("You entered %.3f \n\n", grades[count][count2]);
- } }
-
- Thank you in advance for any assistance you may render.
-
- Bob
- nicatt@oasis.novia.net
-
-